import { InstancedBufferAttribute } from "../../thirdparty/three/imports";
import { BufferAttribute3D } from "./BufferAttribute3D";

export interface InstancedBufferAttribute3D
{
    get _bufferAttribute(): InstancedBufferAttribute;
    set _bufferAttribute(v: InstancedBufferAttribute);
}

export class InstancedBufferAttribute3D extends BufferAttribute3D
{
    declare protected __bufferAttribute: InstancedBufferAttribute;

    constructor(array: ArrayLike<number>, itemSize: number, normalized?: boolean, meshPerAttribute?: number)
    {
        super();
        this._bufferAttribute = new InstancedBufferAttribute(array, itemSize, normalized, meshPerAttribute);
    }

    static get(bufferAttribute: InstancedBufferAttribute)
    {
        let bufferAttribute3d = this._map.get(bufferAttribute) as InstancedBufferAttribute3D;
        if (!bufferAttribute3d)
        {
            bufferAttribute3d = new InstancedBufferAttribute3D(undefined, undefined);
            bufferAttribute3d._bufferAttribute = bufferAttribute;
        }

        return bufferAttribute3d;
    }
}
